package spaceCraft;

/**
 * The <code>Device</code> abstract class represents
 * device basic information using <code>ProductInfo</code>
 * object and its working condition.
 */
public abstract class Device {

    private ProductInfo productInfo;
    private boolean inWorkCondition;

    /**
     * Constructor sets <code>inWorkingCondition</code> to true by default
     *
     * @param productInfo represents basic information about device
     */
    public Device(ProductInfo productInfo) {
        this.productInfo = productInfo;
        inWorkCondition = true;
    }

    /**
     * get basic info about device
     */
    public String getProductInfo() {
        return (productInfo.getName() + " was made by " + productInfo.getManufacturer());
    }

    /**
     * check if device works properly
     *
     * @return inWorkCondition value
     */
    public boolean isInWorkCondition() {
        return inWorkCondition;
    }

    /**
     * set inWorkCondition to false
     */
    public void breakDevice() {
        inWorkCondition = false;
    }

    /**
     * set inWorkCondition to true
     */
    public void repairDevice() {
        inWorkCondition = true;
    }
}
